﻿// JScript File

(function($){
    $.fn.checkall = function(options){
        var defaults = {
		    leaderClass: 'ckLeader',
		    memberClass: 'ckMember'
        };
        
        var options = $.extend(defaults, options);
        
        return this.each(function(){
            var obj = $(this);
            var leader = $("."+options.leaderClass, obj);
            leader.click(function(){
                checkLeader();
            });
            
            function checkLeader(){
                $("."+options.memberClass, obj).each(function(){
                    this.checked = leader.attr('checked');
                });
            }
            
            function checkMember(){
            }
            
        });
        
        
    };
 })(jQuery);
 


 (function ($, undefined){
    $.widget("ui.Popup", {
        options:{
            classCloseBT: "closeBt",
            imageCloseBT: "",
            classOver : ""
        },

        _closeID: "cl",
        
        _overMax: null,

        _create: function (){
            this._closeID += this.element.attr("id");
            this.element.css("display" ,"none");
            this.element.css("position" ,"fixed");
            this.element.css("z-index" ,"20");
//            this.element.css("width", this.options.width);
//            this.element.css("height", this.options.height);
//            this.element.append("<div id='"+this._closeID+"' style='position:absolute;width:30px; height:20px; right:5px; top:5px; display:block'>Close</div>");
            this.element.append("<img alt='close' class='"+this.options.classCloseBT+"' src='"+this.options.imageCloseBT+"' id='"+this._closeID+"' style='position:absolute; display:block;cursor:pointer;'/>");
            var self = this;
            this.element.find("#"+this._closeID).bind("click", function(event){
                self.hide();
            });
            
            this._overMax = $("body div[id='overMax']");
            if(this._overMax.length == 0){
                if(this.options.classOver == ""){
                    $("body form").append("<div id='overMax' style='background-color:white; position:fixed; display:none;'></div>");    
                }
                else{
                    $("body form").append("<div id='overMax' style='position:fixed; display:none;' class='"+this.options.classOver+"'></div>");
                }
                this._overMax = $("body div[id='overMax']");
            }
        },

        _init: function (){
        },

        _setOption: function (key, value){
            this.options[key] = value;
        },

        show : function(){
            var dwidth= window.innerWidth/2;
            var dheight= window.innerHeight/2;
            
            this._overMax.css("width", window.innerWidth +"px");
            this._overMax.css("height", window.innerHeight +"px");
            this._overMax.css("z-index","15");
            this._overMax.css("top","0px");
            this._overMax.css("opacity","0.8");
            this._overMax.css("display", "block");
            
            this.element.css("top", dheight - (this.element.height()/2));
            this.element.css("left", dwidth - (this.element.width()/2));
            this.element.css("display" ,"block");
        },

        hide: function(){
            this.element.css("display" ,"none");
            this._overMax.css("display", "none");
        },

        destroy: function(){
        },

        enable: function(){
        },

        disable: function(){
        }

    });
 })(jQuery);